//
//  YDYLiveTableHeaderView.m
//  DY_Bilibili
//
//  Created by 杨德勇 on 2016/10/8.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYLiveTableHeaderView.h"
#import "YDYCyclePhotoView.h"
#import <Masonry.h>

#import "YDYBanner.h"
#import "YDYLiveContentModel.h"
@interface YDYLiveTableHeaderView()
/** 底部工具条 */
@property (weak, nonatomic) IBOutlet UIView *buttomToolBar;
//图片轮播器的容器
@property (weak, nonatomic) IBOutlet UIView *cyclePhotoViewContain;
/** 图片轮播器 */
@property (nonatomic, weak) YDYCyclePhotoView *cyclePhotoView;

@end
@implementation YDYLiveTableHeaderView

-(void)setLiveContentModel:(YDYLiveContentModel *)LiveContentModel{
    _LiveContentModel = LiveContentModel;
    self.cyclePhotoView.banners = LiveContentModel.banners;
}


-(void)awakeFromNib{
    [super awakeFromNib];
    //375* 130
    [self createCyclePhotoView];
    
}

-(void)createCyclePhotoView{
    YDYCyclePhotoView *cyclePhotoV = [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass([YDYCyclePhotoView class]) owner:nil options:nil] lastObject];

    self.cyclePhotoView = cyclePhotoV;
    [self.cyclePhotoViewContain addSubview:cyclePhotoV];
    [cyclePhotoV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.cyclePhotoViewContain);
    }];

}
-(void)layoutSubviews{
    [super layoutSubviews];
    //把工具栏边缘变圆，只有在这个方法里面才能获得准确的BOUNDS
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.buttomToolBar.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(8, 8)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    maskLayer.frame = self.buttomToolBar.bounds;
    maskLayer.path = path.CGPath;
    self.buttomToolBar.layer.mask = maskLayer;
    
}

#pragma mark -
#pragma mark -点击事件
- (IBAction)centerBtnClick:(UIButton *)sender {
    
    YDYLog(@"你点击了 ”%@“按钮",sender.titleLabel.text);
}
- (IBAction)buttomBtnClick:(UIButton *)sender {
    YDYLog(@"你点击了 ”%@“按钮",sender.titleLabel.text);
}


@end
